<script>
	import { calcDate } from '@/utils/date.js'
	import { tokenTime } from '@/common/setting.js'
	export default {
		data() {
			return { refreshLock: false }
		},
		onLaunch: function() {
			//this.refreshToken()
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			// 定时检测token
			refreshToken() {
				this.refreshTime = setInterval(() => {
					const token = uni.getStorageSync('token')
					const date = calcDate(token.datetime, new Date().getTime())
					if (!date) return
					if (date.seconds >= tokenTime && !this.refreshLock) {
						this.refreshLock = true
						this.$u.api
							.refreshToken(token.content, '000000')
							.then(res => {
								this.$u.func
									.refreshToken(res)
									.then(() => {
										this.refreshLock = false
									})
									.catch(() => {
										this.refreshLock = false
									})
							})
							.catch(() => {
								this.refreshLock = false
							})
					}
				}, 30000)
			}
		}
	}
</script>
<style lang="scss">
	/*uview全局样式*/
	@import 'uview-ui/index.scss';
	/*app全局样式*/
	@import 'static/style/app.scss';
	//H5端引用。玄学问题，我这边在这里引入的css，在APP上无效。前面加/也一样。原因未知...
	//可自行测试在APP上是否有效，如果有效，可在vue里删除css引入的代码。
	/* #ifndef APP-PLUS */
	@import "static/colorui/main.css";
	@import "static/colorui/icon.css";
	@import "static/zaiui/style/app.scss";
/* #endif */
	// 修改checkbox样式
	checkbox.curdCheck .wx-checkbox-input,
	checkbox.curdCheck .uni-checkbox-input {
		border-radius: 50% !important;
		border-color: #c8c9cc !important;
		color: #03A9F4 !important;
	}

	checkbox.curdCheck .wx-checkbox-input-checked,
	checkbox.curdCheck .uni-checkbox-input-checked {
		// background-color: #03A9F4;
		color: #03A9F4 !important;
		border-color: #03A9F4 !important;
	}

	.uni-picker-container,
	.wx-picker-container {
		z-index: 10074;
	}

	uni-modal {
		z-index: 19999 !important;
	}
		
.fl {
	float: left;
  }
  
  .fr {
	float: right;
  }
  
  .tc {
	text-align: center;
  }
  
  .tr {
	text-align: right;
  }
  
  .hide {
	display: none;
  }
  
  .block {
	display: block;
  }
  
  .clearfix {
	clear: left;
  }
  
  .clearfix:after {
	content: '.';
	display: block;
	height: 0;
	clear: both;
	visibility: hidden;
  }
  
  .wrap {
	overflow: hidden;
	/*超出的隐藏*/
	white-space: nowrap;
	text-overflow: ellipsis;
	/*超出的设置为省略号*/
  }
  
  .wrap-2 {
	display: -webkit-box;
	overflow: hidden;
	text-overflow: ellipsis;
	word-wrap: break-word;
	white-space: normal !important;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
  }
  
  .wrap-4 {
	display: -webkit-box;
	overflow: hidden;
	text-overflow: ellipsis;
	word-wrap: break-word;
	white-space: normal !important;
	-webkit-line-clamp: 4;
	-webkit-box-orient: vertical;
  }
  
  
  .flex {
	display: -webkit-flex;
	display: -webkit-box;
	display: flex;
  }
  
  .flex-1 {
	-webkit-flex: 1;
	flex: 1;
	-webkit-box-flex: 1;
	width: 1px;
  }
  
  .flex-c {
	-webkit-box-align: center;
	-webkit-align-items: center;
	align-items: center;
  }
  
  .flex-j {
	-webkit-box-pack: justify;
	-webkit-justify-content: space-between;
	justify-content: space-between;
  }
  
  .flex-cc {
	-webkit-box-align: center;
	-webkit-align-items: center;
	align-items: center;
	-webkit-box-pack: center;
	-webkit-justify-content: center;
	justify-content: center;
  }
</style>
